import http from '@/utils/http'

const BASE_URL = '/system/meet'

export interface MeetResp {
  id: string
  conferenceId: string
  meetingRoomId: string
  meetingRoomName: string
  subject: string
  size: string
  startTime: string
  endTime: string
  conferenceState: string
  passwordGeneral: string
  passwordChair: string
  createUser: string
  meetType: string
  conferenceInfo: string
  createTime: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface MeetDetailResp {
  id: string
  conferenceId: string
  meetingRoomId: string
  meetingRoomName: string
  subject: string
  size: string
  startTime: string
  endTime: string
  conferenceState: number
  passwordGeneral: string
  passwordChair: string
  createUser: string
  meetType: string
  conferenceInfo: string
  createTime: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface MeetQuery {
  sort: Array<string>
  meetType: number | undefined
  conferenceState: number | undefined
  searchDate: string[]
  keywords: string
}
export interface MeetPageQuery extends MeetQuery, PageQuery {}

/** @desc 查询会议列表 */
export function listMeet(query: MeetPageQuery) {
  return http.get<PageRes<MeetResp[]>>(`${BASE_URL}/searchList`, query)
}

/** @desc 查询会议详情 */
export function getMeet(id: string) {
  return http.get<MeetDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增会议 */
export function addMeet(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改会议 */
export function updateMeet(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除会议 */
export function deleteMeet(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出会议 */
export function exportMeet(query: MeetQuery) {
  return http.download(`${BASE_URL}/export`, query)
}

/** @desc 导出会议列表（新接口） */
export function exportMeetList(query: any) {
  return http.get(`${BASE_URL}/searchListExport`, query)
}

/** @desc 获取签到人员 */
export function getSignlist(query) {
  return http.get(`${BASE_URL}/Signlist`, query)
}
/**
 *  获取个人会议
 * @param query 查询参数
 * @returns 返回个人会议列表
 */
export function getUserList(query) {
  return http.get(`/oa/userList`, query)
}

/** @desc 获取个人会议信息（快速导出） */
export function userListFastExport(timeRange: string) {
  return http.get(`/oa/userListFastExport?timeRange=${timeRange}`)
}

/** @desc 查询会议详情 */
export function getMeetDetail(conferenceId: string) {
  return http.get<MeetDetailResp>(`${BASE_URL}/${conferenceId}`)
}

/** @desc 取消子会议 */
export function adminCancelSubMeeting(params: { conferenceId: string, cycleSubConfID: string }) {
  return http.post('/oa/adminCancelSubMeeting', params)
}

/** @desc 取消会议 */
export function adminCancelMeeting(conferenceId: string) {
  return http.get('/oa/adminCancelMeeting', { conferenceId })
}

/** @desc 取消我的会议 */
export function adminCancelMyMeeting(conferenceId: string) {
  return http.get('/oa/adminCancelMyMeeting', { conferenceId })
}

/** @desc 取消我的子会议 */
export function adminCancelMySubMeeting(params: { conferenceId: string, cycleSubConfID: string }) {
  return http.post('/oa/adminCancelMySubMeeting', params)
}
